home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fsmake / fsmake.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-10  |  5.0 KB  |  186 lines

  1. /*
  2.  * fsmake.h --
  3.  *
  4.  *    Declarations for the fsmake program.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/admin/fsmake/RCS/fsmake.h,v 1.2 90/10/10 16:00:36 rab Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _FSMAKE
  19. #define _FSMAKE
  20. #include <sprite.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <unistd.h>
  24. #include <string.h>
  25. #include <bstring.h>
  26. #include <sys/types.h>
  27. #include <sys/file.h>
  28. #include <sys/dir.h>
  29. #include <option.h>
  30. #include <disk.h>
  31. #include <host.h>
  32. #include <dev/scsi.h>
  33. #include <sys/stat.h>
  34. #include <sys/time.h>
  35.  
  36. #if defined(sprite) || defined(sun)
  37. #define S_GFDIR     S_IFDIR
  38. #define S_GFMT      S_IFMT
  39. #define S_GFLNK     S_IFLNK
  40. #define S_GFREG      S_IFREG
  41. #endif
  42.  
  43. /*
  44.  * This suffix on a file indicates that it contains information for
  45.  * building a Sprite device.
  46.  */
  47.  
  48. #define DEVICE_SUFFIX ".SPRITE_DEV"
  49.  
  50. /*
  51.  * The following structures are used to send a raw scsi command to the
  52.  * disk.  These really don't belong here.  Someday there should be a 
  53.  * seperate header file for defining the format of scsi commands.
  54.  */
  55.  
  56. typedef struct {
  57. #if BYTE_ORDER == BIG_ENDIAN
  58.     unsigned char command;        
  59.     unsigned char lun        :3;
  60.     unsigned char pad1        :4;
  61.     unsigned char reladr    :1;
  62.     unsigned char addr3;
  63.     unsigned char addr2;
  64.     unsigned char addr1;
  65.     unsigned char addr0;
  66.     unsigned char pad2;
  67.     unsigned char pad3;
  68.     unsigned char pad4        :7;
  69.     unsigned char pmi        :1;
  70.     unsigned char control;
  71. #else
  72.     unsigned char command;        
  73.     unsigned char reladr    :1;
  74.     unsigned char pad1        :4;
  75.     unsigned char lun        :3;
  76.     unsigned char addr3;
  77.     unsigned char addr2;
  78.     unsigned char addr1;
  79.     unsigned char addr0;
  80.     unsigned char pad2;
  81.     unsigned char pad3;
  82.     unsigned char pmi        :1;
  83.     unsigned char pad4        :7;
  84.     unsigned char control;
  85. #endif
  86. } ReadCapacityCommand;
  87.  
  88.  
  89. /*
  90.  * This structure is passed to Fs_IOControl to do an IOC_SCSI_COMMAND
  91.  * ioctl.
  92.  */
  93. typedef struct  {
  94.     Dev_ScsiCommand    hdr;
  95.     ReadCapacityCommand cmd;
  96. } ScsiCmd;
  97.  
  98. /*
  99.  * The result of an IOC_SCSI_COMMAND.
  100.  */
  101. typedef struct {
  102.     Dev_ScsiStatus    hdr;
  103.     union {
  104.     struct {
  105.         unsigned char    addr3;
  106.         unsigned char    addr2;
  107.         unsigned char    addr1;
  108.         unsigned char    addr0;
  109.         unsigned char    size3;
  110.         unsigned char    size2;
  111.         unsigned char    size1;
  112.         unsigned char    size0;
  113.     } result;
  114.     unsigned char    data[3*1024];
  115.     } info;
  116. } CmdStatus;
  117.  
  118. /*
  119.  * Structure used to peruse Sprite directories.
  120.  */
  121. typedef struct DirIndexInfo {
  122.     Fsdm_FileDescriptor *fdPtr;                  /* The file descriptor being
  123.                           * read. */
  124.     int         blockNum;             /* Block that is being read, 
  125.                           * written, or allocated. */
  126.     int         blockAddr;             /* Address of directory block
  127.                           * to read. */
  128.     int         dirOffset;             /* Offset of the directory entry 
  129.                           * that we are currently examining 
  130.                           * in the directory. */
  131.     char     dirBlock[FS_BLOCK_SIZE];    /* Where directory data is 
  132.                           * stored. */
  133. } DirIndexInfo;
  134.  
  135. /*
  136.  * Macro to get a pointer into the bit map for a particular block.
  137.  */
  138. #define BlockToCylinder(headerPtr, blockNum) \
  139.     (blockNum) / (headerPtr)->geometry.blocksPerCylinder
  140.  
  141. #define GetBitmapPtr(headerPtr, bitmapPtr, blockNum) \
  142.   &((bitmapPtr)[BlockToCylinder(headerPtr, blockNum) * \
  143.   bytesPerCylinder + (blockNum) % (headerPtr)->geometry.blocksPerCylinder / 2])
  144.  
  145. /*
  146.  * Macros to convert physical block numbers to virtual block numbers. All direct
  147.  * blocks are virtual, indirect blocks are physical.
  148.  */
  149. #define VirtToPhys(blockNum) \
  150.     ((blockNum) + (headerPtr)->dataOffset * FS_FRAGMENTS_PER_BLOCK)
  151.  
  152. #define PhysToVirt(headerPtr,blockNum) \
  153.     ((blockNum) - (headerPtr)->dataOffset * FS_FRAGMENTS_PER_BLOCK)
  154.  
  155. /*
  156.  * Macro to mark the file descriptor bit map.
  157.  */
  158. #define MarkFDBitmap(num,bitmapPtr) \
  159.     (bitmapPtr)[(num) >> 3] |= (1 << (7 -((num)  & 7)))
  160.  
  161. #define Max(a,b) ((a) > (b)) ? (a) : (b)
  162.  
  163. extern Boolean printOnly;
  164.  
  165. #undef _ARGS_
  166. #ifdef __STDC__
  167. #define    _ARGS_(x)    x
  168. #else 
  169. #define    _ARGS_(x)    ()
  170. #endif 
  171.  
  172. extern ReturnStatus ConfirmDiskSize _ARGS_ ((int fid,
  173.     Disk_Label *labelPtr, int *sizes)); /* Size of partitions. */
  174. extern ReturnStatus Reconfig _ARGS_((int fid, Boolean disktab,
  175.     char *disktabName, char *diskType, Disk_NativeLabelType labelType,
  176.     int scsiDisk, Disk_Label **labelPtrPtr));
  177. extern ReturnStatus Repartition _ARGS_((int fid, Boolean disktab,
  178.     char *disktabName, char *diskType, Disk_NativeLabelType labelType,
  179.     int partition, int *sizes, Disk_Label **labelPtrPtr));
  180. extern ReturnStatus InventConfig _ARGS_((int fid, Disk_Label *labelPtr));
  181. extern ReturnStatus ConfirmDiskSize _ARGS_((int fid,
  182.     Disk_Label *labelPtr, int *sizes));
  183.  
  184. #endif /* _FSMAKE */
  185.  
  186.